import { createRouter, createWebHistory } from 'vue-router'
import Layout from '@/views/Layout/Layout.vue'
import Home from '@/views/Home/Home.vue'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  //滚动条重置
  scrollBehavior () {
    return { top: 0 }
  },
  routes: [
    
   {
    path:'/',
    name:'layout',
    component:Layout,
    children:[
      {
        path:'',
        name:'home',
        component:Home
      },
      {
        path:'/category/:id',
        name:'category',
        component:()=>import('@/views/Category/Category.vue')
      },
      {
        path:"/category/sub/:id",
        name:'subcategory',
        component:()=>import('@/views/Shoes/shoeDetail.vue')
      },
      {
        path:"/detail/:id",
        name:'detail',
        component:()=>import('@/views/GoodsDetail/GoodsDetail.vue')
      },
        {
            path: '/address',
            name: 'address',
            component: () => import('@/views/Address/addressList.vue')
        },
        {
            path: '/address/add',
            name: 'addAddress',
            component: () => import('@/views/Address/addressForm.vue')
        },
        {
            path: '/address/edit',
            name: 'editAddress',
            component: () => import('@/views/Address/addressForm.vue')
        },
        {
            path: '/payment',
            name: 'Payment',
            component: () => import('@/views/Payment/payment.vue')
        },
        {
            path: '/order/success',
            name: 'OrderSuccess',
            component: () => import('@/views/Payment/OrderSuccess.vue')
        },
        {
            path: '/order/list',
            name: 'OrderList',
            component: () => import('@/views/Orders/OrderList.vue')
        },
        {
            path: '/search',
            name: 'SearchResult',
            component: () => import('@/views/SearchResult/SearchResult.vue'),
            meta: { title: '搜索结果' }
        }
    ]
   },
   {
    path:'/login',
    name:'login',
    component:()=>import('@/views/Login/Login.vue')
   },
      {
          path: '/checkout',
          name: 'checkout',
          component: () => import('@/views/Orders/ordersPayment.vue')
      }
  ],
})

export default router
